<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 获取系统时间
        let date=new Date()

        let year=date.getFullYear()
        let mou=date.getMonth()+1;
        let day=date.getDate()

        let h=date.getHours()
        let m=date.getMinutes()
        let s=date.getSeconds()

        // 先变为字符串 再补零
        let omou=(mou.toString().padStart(2,'0'));
        let oday=(day.toString().padStart(2,'0'));
        let oh=(h.toString().padStart(2,'0'));
        let om=(m.toString().padStart(2,'0'));
        let os=(s.toString().padStart(2,'0'));

        let str=`
            ${year}-${omou}-${oday}  ${oh}:${om}:${os}
        `;
        
        // console.log(s);
        // 2023-02-27   08:36:27
        console.log(str);
    </script>
</body>
</html>